const M=require("ming_node")


var request = require('request');

const post  = async (api, params = {},headers) => {
    let options = {
        'method': 'POST',
        "url":api,
        "headers":headers||{},
        "json":params
    }
    return new Promise((resolve, reject) => {
        request(options,function (error, response, body) {
            if(error){
                reject(error);
            }else {
                let bj= body;
                resolve(bj);
            }
        })
    })
}

const get  = async (api, params = {},headers) => {
    let options = {
        'method': 'GET',
        "url":api,
        "headers":headers||{},
        "qs":params
    }
    return new Promise((resolve, reject) => {
        request(options,function (error, response, body) {
            if(error){
                reject(error);
            }else {
                let bj= JSON.parse(body);
                resolve(bj);
            }
        })
    })
}


M.request={}
M.request.get=get;
M.request.post=post;






async function main(){

    // let r= await M.request.post("https://okaiig-owquzr-8888.preview.myide.io/ming/add",{
    //     name:"zs"
    // })
    // console.log(r)

     r=await M.request.get("https://okaiig-owquzr-8888.preview.myide.io/ming/list",{name:"zs"})
    console.log(r)
}

main()